ARD2  1.00 for Rev B. Hardware
Airbag Reference Demonstrator using MPC5604P
MailDelivery.h File Reference

Lower layer of scheduler in charge of dealing with delivering messages from one point to the other. More...

Go to the source code of this file.

Defines

#define TRUE   (1u)
#define CLEAR   (0u)
#define BITS_IN_NIBBLE   (4u)
#define BITS_IN_BYTE   (8u)
#define BITS_IN_32   (32u)
#define BITS_IN_16   (16u)
#define BYTES_IN_32   (4u)
#define BYTES_IN_16   (2u)
#define MAILDELIVERY_OUTBOX1_DMA_CH   (0x0Eu)
#define MAILDELIVERY_OUTBOX2_DMA_CH   (0x0Fu)
#define MAILDELIVERY_INBOX1_DMA_CH   (0x0Cu)
#define MAILDELIVERY_INBOX2_DMA_CH   (0x0Du)
#define MAILDELIVERY_INBOX1_DMA_INDEX_START   (0u)
#define MAILDELIVERY_INBOX1_DMA_INDEX_END   (INBOX_MAX_BUFFER_CNT - 1)
#define MAILDELIVERY_INBOX2_DMA_INDEX_START   (INBOX_MAX_BUFFER_CNT)
#define MAILDELIVERY_INBOX2_DMA_INDEX_END   ((INBOX_MAX_BUFFER_CNT * 2u) - 1u)
#define OUTBOX_MAX_BUFFER_CNT   (48u)
#define INBOX_MAX_BUFFER_CNT   (48u)
#define MAILBOX_WRITING_ALLOWED   (0xA0u)
#define MAILBOX_WRITING_PROHIBITED   (0x0Au)
#define OUTBOX_ACTIVE_OUTBOX_IS_1   (0u)
#define OUTBOX_ACTIVE_OUTBOX_IS_2   (OUTBOX_MAX_BUFFER_CNT + 1u)
#define MAILBOX_ACTIVE_INBOX_IS_1   (-1)
#define MAILBOX_ACTIVE_INBOX_IS_2   (-2)
#define MAILBOX_NO_PREVIOUS_INBOX   (0u)
#define MAILBOX_CAPACITY_HAS_BEEN_REACHED   (0x20u)
#define MAILBOX_IS_BEING_WRITTEN   (0x10u)

Functions

uint8_t u8fnMailDeliveryOfOutboxInit (uint32_t *pu32Outbox, uint32_t *pu32Output, uint8_t u8DMAChannel)
 This function configures a given DMA for outbox operation through. a given global buffer.
uint8_t u8fnMailDeliveryToInboxInit (uint16_t *pu16Input)
 This function configures channels MAILDELIVERY_INBOX1_DMA_CH to MAILDELIVERY_INBOX1_PERSO_DMA_CH_END as the first inbox delivery DMA channels, and MAILDELIVERY_INBOX2_DMA_CH to MAILDELIVERY_INBOX2_PERSO_DMA_CH_END as the second inbox delivery channels. It links pu16Input to the source. Destinations will be dynamically allocated.
void vfnMailboxInit (void)
 This function clears all contents of both inbox and outbox.
uint8_t u8fnMailboxAppendToDSPIOutbox (uint8_t u8DSPIInstance, uint8_t u8CS, uint8_t u8ContCS, uint8_t u8EndOfQueueFlag, uint16_t *pu16Msg, uint16_t u16Size)
 This function appends a 16-bit message to a 32-bit outbox. The assumption is that PUSHR within the DSPI will be written, and the upper word is formatted by calling u32fnFormatDSPIPUSHR(). This function will check if there's enough space, and if there is, will add the formatted 32-bit word to the queue.
uint8_t u8fnMailboxAppendToCompositeDSPIOutbox (uint8_t u8DSPIInstance1, uint8_t u8DSPIInstance2, uint8_t u8CS, uint16_t *pu16Msg1, uint16_t *pu16Msg2, uint16_t u16SizeAtOrigin)
 This function appends an odd-number message to two 32-bit outboxes. It behaves in a similar fashion to u8fnMailboxAppendToDSPIOutbox, except it assumes that the message will be constructed out of two CTAR locations, rendering two units within the outbox FIFO. This technique allows to create 16+ bit messages.
uint8_t u8fnMailboxAppendToOutbox (uint32_t *pu32Mailbox, uint32_t u32Message)
 This function appends a 32-bit message to a 32-bit outbox. It also increments the mailbox active messages count if successful.
uint8_t u8fnMailboxAppendToInbox (const uint16_t *pu16MsgResponse, uint16_t u16Size)
 This function appends a 16-bit message to a given RAM location.
void vfnMailboxSwitchActiveMailboxes (void)
 Switches from Inbox and outbox 1/2 to 2/1.
void vfnMailDeliveryTriggerOutbox (uint8_t u8DMAMuxChannel, uint8_t u8Enable)
 Triggers a particular outbox by connecting the correct DMA Mux channel to SPI Tx empty. NOTE:

Variables

vuint32_t gau32DSPIOutbox [(OUTBOX_MAX_BUFFER_CNT+1u)*2u]
vuint16_t gau16DSPIInbox [OUTBOX_MAX_BUFFER_CNT+1u]
vuint8_t gu8MailboxActiveOutboxOffset
vuint8_t gu8InboxDMA
vuint8_t gu8InactiveInboxDMA
vuint8_t gu8OutboxDMA
vuint8_t gu8InactiveOutboxDMA

Detailed Description

Lower layer of scheduler in charge of dealing with delivering messages from one point to the other.

Copyright (c) 2011 Freescale Semiconductor Freescale Confidential Proprietary

Author:
Freescale Semiconductor
SASD Automotive
R11515
Version:
Date:
Warning:
(If needed)

History:


Function Documentation

uint8_t u8fnMailboxAppendToCompositeDSPIOutbox ( uint8_t  u8DSPIInstance1,
uint8_t  u8DSPIInstance2,
uint8_t  u8CS,
uint16_t *  pu16Msg1,
uint16_t *  pu16Msg2,
uint16_t  u16SizeAtOrigin 
)

This function appends an odd-number message to two 32-bit outboxes. It behaves in a similar fashion to u8fnMailboxAppendToDSPIOutbox, except it assumes that the message will be constructed out of two CTAR locations, rendering two units within the outbox FIFO. This technique allows to create 16+ bit messages.

Parameters:
u8DSPIInstance1,:A combination of SPI instance and CTAR. Only CTAR is used, and it's used for the first half of the message.
u8DSPIInstance2,:A combination of SPI instance and CTAR. Only CTAR is used, and it's used for the second half of the message.
u8CS,:Mask to the active chip select.
pu16Msg1,:pointer to the first half of the message that will be formatted using the first CTAR given in u8DSPIInstance1.
pu16Msg2,:pointer to the second half of the message that will be formatted using the first CTAR given in u8DSPIInstance2.
u16SizeAtOrigin,:Number of messages to be added. A combination of two pu16Msg1 and puMsg2 words count as one.
Returns:
CLEAR if function executed without problems, MAILBOX_CAPACITY_HAS_BEEN_REACHED in case the outbox cannot hold anymore elements.
uint8_t u8fnMailboxAppendToDSPIOutbox ( uint8_t  u8DSPIInstance,
uint8_t  u8CS,
uint8_t  u8ContCS,
uint8_t  u8EndOfQueueFlag,
uint16_t *  pu16Msg,
uint16_t  u16Size 
)

This function appends a 16-bit message to a 32-bit outbox. The assumption is that PUSHR within the DSPI will be written, and the upper word is formatted by calling u32fnFormatDSPIPUSHR(). This function will check if there's enough space, and if there is, will add the formatted 32-bit word to the queue.

Parameters:
u8DSPIInstance,:A combination of SPI instance and CTAR. Only CTAR is used.
u8CS,:Mask to the active chip select.
u8ContCS,:1 if chip select should be continuous with next word, 0 otherwise.
u8EndOfQueueFlag,:1 if the EndOfQueue should be set at the end of the transmission, possibly generating and EOQ interrupt, 0 otherwise.
pu16Msg,:pointer to the 16-bit word(s) to be placed in the box.
u16Size,:Number of messages to be added.
Returns:
CLEAR if function executed without problems, MAILBOX_CAPACITY_HAS_BEEN_REACHED in case the outbox cannot hold anymore elements.
uint8_t u8fnMailboxAppendToInbox ( const uint16_t *  pu16MsgResponse,
uint16_t  u16Size 
)

This function appends a 16-bit message to a given RAM location.

Parameters:
pu16MsgResponse,:pointer to the location where the result should be stored once it arrives.
u16Size,:Number of words to be incrementally stored.
Returns:
Always zero.
uint8_t u8fnMailboxAppendToOutbox ( uint32_t *  pu32Mailbox,
uint32_t  u32Message 
)

This function appends a 32-bit message to a 32-bit outbox. It also increments the mailbox active messages count if successful.

Parameters:
pu32Mailbox,:pointer to the mailbox to which the message will be appended.
u32Msg,:Message to be appended.
Returns:
CLEAR if function executed without problems, MAILBOX_CAPACITY_HAS_BEEN_REACHED in case the outbox cannot hold anymore elements.
uint8_t u8fnMailDeliveryOfOutboxInit ( uint32_t *  pu32Outbox,
uint32_t *  pu32Output,
uint8_t  u8DMAChannel 
)

This function configures a given DMA for outbox operation through. a given global buffer.

Parameters:
pu32Outbox,:Buffer where 32-bit words will be stacked in a queue for output operation. First word will always be a count of elements in the queue.
pu32Output,:Register that will be written with 32-bit elements in the Outbox.
u8DMAChannel,:Channel used to perform this transfer.
Returns:
Always zero.
uint8_t u8fnMailDeliveryToInboxInit ( uint16_t *  pu16Input)

This function configures channels MAILDELIVERY_INBOX1_DMA_CH to MAILDELIVERY_INBOX1_PERSO_DMA_CH_END as the first inbox delivery DMA channels, and MAILDELIVERY_INBOX2_DMA_CH to MAILDELIVERY_INBOX2_PERSO_DMA_CH_END as the second inbox delivery channels. It links pu16Input to the source. Destinations will be dynamically allocated.

Parameters:
pu16Input,:Source for data to be copied using DMAs..
Returns:
Always zero.
void vfnMailboxInit ( void  )

This function clears all contents of both inbox and outbox.

Parameters:
none
Returns:
void
void vfnMailboxSwitchActiveMailboxes ( void  )

Switches from Inbox and outbox 1/2 to 2/1.

Parameters:
None
Returns:
Void.
void vfnMailDeliveryTriggerOutbox ( uint8_t  u8DMAMuxChannel,
uint8_t  u8Enable 
)

Triggers a particular outbox by connecting the correct DMA Mux channel to SPI Tx empty. NOTE:

Parameters:
u8DMAMuxChannel,:As described by name.
u8Enable,:non-zero for enable, zero for disable.
Returns:
Void.
Warning:
Currently hard-coded to DSPI0.

Variable Documentation

vuint32_t gau32DSPIOutbox[(OUTBOX_MAX_BUFFER_CNT+1u)*2u]

Scheduler's SPI Outbox FIFO

Complement to to gu8InboxDMA - indicates inactive DMA channel

Complement to to gu8OutboxDMA - indicates inactive DMA channel

vuint8_t gu8InboxDMA

Indicates the next DMA channel to be used for reception of incoming message

Determines which half of the outbox is being used; used as an index offset

vuint8_t gu8OutboxDMA

Indicates the next DMA channel to be used for transmission of outgoing message